// DownProcess.cpp: implementation of the CDownProcess class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "DownProcess.h"

CTVPtrList<CDownProcess> g_listDownFinish;

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CDownProcess::CDownProcess(UINT nSiteID, HTTPDOWNLOAD& httpdown)
: m_bWantStop(false)
, CHttpDownload( httpdown )
, m_nSiteID(nSiteID)
{
}

CDownProcess::~CDownProcess()
{
}

void CDownProcess::ThreadProcMain(void)
{
	Execute();
	g_listDownFinish.Push( this);
	if ( g_hMainWnd )
		::PostMessage( g_hMainWnd, WM_DOWNLOAD_PROCESS_END, 0, (LPARAM)this );
}

BOOL CDownProcess::Start()
{
	m_bWantStop = FALSE;
	return StartThread();
}

void CDownProcess::Stop()
{
	m_bWantStop = TRUE;
	WaitForStop();
}
